package handler

import (
	"ebip/internel/errs"
	"ebip/internel/service/enterprise_service"
	"ebip/internel/types"
	"ebip/pkg/ginl/wrap_gin"
	"github.com/gin-gonic/gin"
)

// @Description
// @Author 代码小学生王木木

type EnterpriseHandler struct {
	types.Res
	entSvc enterprise_service.EnterParser
}

func NewEnterpriseHandler(entSvc enterprise_service.EnterParser) *EnterpriseHandler {
	return &EnterpriseHandler{
		Res:    types.Res{},
		entSvc: entSvc,
	}
}

func (h *EnterpriseHandler) AdminSearchList(ctx *gin.Context) (wrap_gin.Result, error) {
	var res = types.AdminEnterpriseListRepose{
		Items: []types.Enterprise{},
		Total: 10,
	}
	return h.SuccesJson(res), nil
}

// ParseEnterpriseAsync
//
//	@Description: 异步解析Excel数据
func (h *EnterpriseHandler) ParseEnterpriseAsync(ctx *gin.Context, req types.ParseExcelRequest) (wrap_gin.Result, error) {
	return h.SuccesJson(1), nil
}

// ParseEnterpriseSync
//
//	@Description: 同步解析Excel数据
func (h *EnterpriseHandler) ParseEnterpriseSync(ctx *gin.Context, req types.ParseExcelRequest) (wrap_gin.Result, error) {
	err := h.entSvc.ParserEnterpriseExcel(ctx, req.FileAbsPath)
	if err != nil {
		return h.ErrX(errs.ErrParserExcel), err
	}
	return h.SuccesJson(nil), nil
}
